package cn.itcast.service.impl;

import cn.itcast.dao.StudentDao;
import cn.itcast.domain.StuAndCourse;
import cn.itcast.domain.Student;
import cn.itcast.service.StudentService;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("studentService")
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;

    public List<Student> findAll() {
        System.out.println("业务层：查询所有账户...");
        return studentDao.findAll();
    }

    public Student findByStuAndPas(@Param("username") String username,
                                   @Param("password") String password){
        return studentDao.findByStuAndPas(username,password);
    }

    public List<StuAndCourse> findByIdtoCourse(@Param("username") String username){
        return studentDao.findByIdtoCourse(username);
    }

    public Student findById(@Param("username")String username) {
        return studentDao.findById(username);
    }

    public void updatePass(@Param("oldpassword")String oldpassword,
                           @Param("newpassword")String newpassword,
                           @Param("confirmpassword")String confirmpassword,
                           @Param("username")String username){
        studentDao.updatePass(oldpassword,newpassword,confirmpassword,username);

    }


}
